package com.basic.inspection.service.impl;

import com.basic.common.exception.business.DataException;
import com.basic.inspection.controller.res.PumpPerformanceDataRes;
import com.basic.inspection.dao.mapper.PumpPerformanceDataExMapper;
import com.basic.inspection.dao.mapper.PumpPerformanceDataMapper;
import com.basic.inspection.domain.PumpPerformanceDataBo;
import com.basic.inspection.service.PumpPerformanceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;

/**
 * @Author wei
 * @Date 2024/9/2
 * @Description 泵站绩效分析表-逻辑处理
 */

@Service
public class PumpPerformanceDataServiceImpl implements PumpPerformanceDataService {

    @Autowired
    private PumpPerformanceDataMapper pumpPerformanceDataMapper;

    @Autowired
    private PumpPerformanceDataExMapper pumpPerformanceDataExMapper;

    /**
     * 泵站绩效分析-实际额定功率,能耗比
     * @param bo 实体类
     * @return List<PumpPerformanceDataRes>
     */
    @Override
    public List<PumpPerformanceDataRes> selPfdPowerAndEnergy(PumpPerformanceDataBo bo) {
        if (bo.getStationDataId() == null) {
            throw new DataException("泵站id不可为空");
        }
        List<PumpPerformanceDataRes> pumpPerformanceDataRes = pumpPerformanceDataExMapper.selPfdPowerAndEnergy(bo);
        if (pumpPerformanceDataRes != null && !pumpPerformanceDataRes.isEmpty()) {
            return pumpPerformanceDataRes;
        }
        return Collections.emptyList();
    }
}
